﻿using Sai.Core.Introspection;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Xml.Serialization;

namespace Sai.Core 
{
    public class NamespaceListing
    {
        private List<TypeName> types = new List<TypeName>();

        /// <summary>
        /// The name of the assembly.
        /// </summary>
        [XmlAttribute("Name")]
        public string Name { get; set; }

        [XmlArray("Types", IsNullable = false)]
        [XmlArrayItem("Type", typeof(TypeName))]
        public Collection<TypeName> Types
        {
            get
            {
                if (this.types.Any())
                {
                    return new Collection<TypeName>(this.types);
                }

                return null;
            }
        }

        public void Add(TypeName typeName)
        {
            this.types.Add(typeName);
        }

        public void AddRange(IEnumerable<TypeName> typeNames)
        {
            this.types.AddRange(typeNames);
        }
    }
}
